package org.example.day20240829Calendar;

public class Main {

    static class Money implements Cloneable{
        int m_money;

        public Money(int m_money) {
            this.m_money = m_money;
        }

        @Override
        protected Object clone() throws CloneNotSupportedException {
            return super.clone();
        }
    }
    static class People implements Cloneable{
        int age;
        String name;
        Money money;

        public People(int age, String name, Money money) {
            this.age = age;
            this.name = name;
            this.money = money;
        }

        @Override
        protected Object clone() throws CloneNotSupportedException {
            People tmp = (People) super.clone();
            tmp.money = (Money) this.money.clone();
            return tmp;
        }
    }

    public static void main(String[] args) throws CloneNotSupportedException {
        Money money = new Money(20000);
        People people = new People(5,"zhangsan",money);
        People people1 = (People) people.clone();
        people.money.m_money = 500;
        System.out.println(people1.money.m_money);
    }
}
